
import 'package:flutter_base/common/entitys/entitys.dart';
import 'package:flutter_base/common/entitys/role_list_by_user_entity.dart';
import 'package:flutter_base/common/utils/utils.dart';
import 'package:flutter_base/common/values/values.dart';
import 'package:flutter/material.dart';

class BaseAPI {
  ///获取fir.im token
  static Future downloadToken({
    required BuildContext context,
    params,
    bool refresh = false,
    bool cacheDisk = false,
  }) async {
    var response = await HttpUtil().get(
      'http://api.bq04.com/apps/60fe7cec23389f27e4cf3e55/download_token?api_token=59d330e18e8928dbf56dbb3922e1e8e6',
      context: context,
      params: params,
      refresh: refresh,
      cacheDisk: cacheDisk,
      cacheKey: STORAGE_INDEX_NEWS_CACHE_KEY,
    );
    return response;
  }

  ///安装
  static Future install({
    required BuildContext context,
    downloadToken,
    bool refresh = false,
    bool cacheDisk = false,
  }) async {
    var response = await HttpUtil().get(
      'http://download.bq04.com/apps/60fe7cec23389f27e4cf3e55/install?download_token=$downloadToken',
      context: context,
      refresh: refresh,
      cacheDisk: cacheDisk,
      cacheKey: STORAGE_INDEX_NEWS_CACHE_KEY,
    );
    return response;
  }

  ///版本查询
  static Future checkUpdate({
    required BuildContext context,
    downloadToken,
    bool refresh = false,
    bool cacheDisk = false,
  }) async {
    var response = await HttpUtil().get(
      'http://api.bq04.com/apps/latest/60fe7cec23389f27e4cf3e55?api_token=59d330e18e8928dbf56dbb3922e1e8e6',
      context: context,
      refresh: refresh,
      cacheDisk: cacheDisk,
      cacheKey: STORAGE_INDEX_NEWS_CACHE_KEY,
    );
    return response;
  }

  ///获取角色权限
  static Future<RoleListByUserEntity> roleListByUser({
    required BuildContext context,
    params,
    bool refresh = false,
    bool cacheDisk = false,
  }) async {
    var response = await HttpUtil().get(
      '/zjl/api/auth/industry/common/roleListByUser',
      context: context,
      params: params,
      refresh: refresh,
      cacheDisk: cacheDisk,
      cacheKey: STORAGE_INDEX_NEWS_CACHE_KEY,
    );
    return RoleListByUserEntity.fromJson(response);
  }

  ///获取角色权限
  static Future<RoleListByUserEntity> userByRoleList({
    required BuildContext context,
    params,
    bool refresh = false,
    bool cacheDisk = false,
  }) async {
    var response = await HttpUtil().get(
      '/zjl/api/auth/industry/common/userByRoleList',
      context: context,
      params: params,
      refresh: refresh,
      cacheDisk: cacheDisk,
      cacheKey: STORAGE_INDEX_NEWS_CACHE_KEY,
    );
    return RoleListByUserEntity.fromJson(response);
  }

  ///获取角色权限
  static Future<BaseResponseEntity> qrcodeScan({
    required BuildContext context,
    params,
    bool refresh = false,
    bool cacheDisk = false,
  }) async {
    var response = await HttpUtil().post(
      '/zjl/api/auth/base/system/qrcodeScan',
        params: params, context: context,toast: true);
    return BaseResponseEntity.fromJson(response);
  }
}